<?php

namespace App\library\services;

use App\Models\Config;
use Illuminate\Support\Facades\Redis;

class ConfigService extends BaseServices
{
    /**
     * Author:Zhongyuan Lu
     * 获取配置信息
     * @param $field
     * @return mixed
     */
    public static function getValue($field)
    {
        Redis::select(4);
        $value = Redis::get("config:{$field}");
        if (empty($value)) {
            $value = Config::getValue($field);
            Redis::set("config:{$field}",$value);
        }
        return $value;
    }

    /**
     * Author:Zhongyuan Lu
     * 通过id获取数据
     * @param $id
     * @return mixed
     */
    public static function getById($id)
    {
        return Config::find($id);
    }
}
